// coding: utf-8
// @Author : lryself
// @Date : 2020/10/29 22:27
// @Software: GoLand

package main

func main() {
	
}

type TreeNode struct {
    Val int
    Left *TreeNode
    Right *TreeNode
}

func sumNumbers(root *TreeNode) int {
	return sumnode(root, 0)
}
func sumnode(root *TreeNode, sum int) int {
	if root==nil{
		return 0
	}
	sum = sum*10+root.Val
	if root.Left==nil&&root.Right==nil{
		return sum
	}
	return sumnode(root.Left, sum)+sumnode(root.Right,sum)
}